<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@page
	language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<html>
<head>
<title>变电站设备</title>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<meta name="GENERATOR"
	content="Rational® Application Developer™ for WebSphere® Software">
<link rel="stylesheet" href="${pageContext.request.contextPath}/js/ext/resources/css/ext-all.css"
	type="text/css">
<link rel="stylesheet" href="${webctx }/js/ext/resources/css/xtheme-gray.css" type="text/css">
<script language="JavaScript" src="${pageContext.request.contextPath}/js/ext/adapter/ext/ext-base.js"></script>
<script language="JavaScript" src="${pageContext.request.contextPath}/js/ext/js/ext-all.js"></script>
<script language="JavaScript"
	src="${pageContext.request.contextPath}/js/ext/resources/locale/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/extInterceptor.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath}/images/dcfs/dcfs.css" type="text/css">
<script type="text/javascript">
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget='side';

var sm = new Ext.grid.CheckboxSelectionModel();
var MyViewport = Ext.extend(Ext.Viewport, {
	xtype: "viewport", 
	layout: 'fit',
	listeners:{
		"afterrender":function(){
			Ext.getCmp("bdz_grid").getStore().load();
		}
	},
	initComponent: function () {
		this.items = {
			xtype:"grid",
          	title:"变电站系统设备信息",
	        id:'bdz_grid',
	        border: false,
           //frame: false,
           //iconCls:"sxly",       
            loadMask:true,
            sm:sm,
            store: {
                 xtype:"jsonstore",
				 url:"BDZ_SB_JBXX_Servlet",
				 root:"root",
	             fields: [
              		{name:"BDZ_SB_SBND"},{name:"BDZ_SB_DJDM"},{name:"BDZ_SB_FRDM"},{name:"BDZ_MC"},
              		{name:"BDZLX_BH"},{name:"BDZLX_MC"},{name:"BDZ_DD"},{name:"BDZ_SB_BH"},
              		{name:"BDZ_ZBYQ_MC"},{name:"BDZ_ZBYQ_XH"},{name:"BDZ_SB_SL"},{ name:"BDZ_SB_ZGDY"},
              		{name:"BDZ_SB_EDGL"},{name:"BDZ_SB_JSFS"},{name:"BDZ_JD_D"},{name:"BDZ_JD_F"},
              		{name:"BDZ_JD_M"},{name:"BDZ_WD_D"},{name:"BDZ_WD_F"},{name:"BDZ_WD_M"},
              		{name:"BDZ_SB_QDSJ"},{name:"BDZ_SB_SBDW"},{name:"BD_JD"},{name:"BD_WD"}
	             ]
            },
			columns:[
				  sm,
				  {header:"设备编号",dataIndex:"BDZ_SB_BH"},
                  {header:"申报年度",dataIndex:"BDZ_SB_SBND"},
              	  {header:"等级代码",dataIndex:"BDZ_SB_DJDM"},
              	  {header:"法人代码",dataIndex:"BDZ_SB_FRDM"},
              	  {header:"变电站名称",dataIndex:"BDZ_MC"},
              	  {header:"变电站类型编号",dataIndex:"BDZLX_BH"},
              	  {header:"变电站类型名称",dataIndex:"BDZLX_MC"},
              	  {header:"变电站地点",dataIndex:"BDZ_DD"},
              	  
              	  {header:"主变压器名称",dataIndex:"BDZ_ZBYQ_MC"},
              	  {header:"主变压器型号",dataIndex:"BDZ_ZBYQ_XH"},
              	  {header:"数量",dataIndex:"BDZ_SB_SL"},
              	  {header:"最高电压（kV）",dataIndex:"BDZ_SB_ZGDY"},
              	  {header:"额定功率（kVA）",dataIndex:"BDZ_SB_EDGL"},
              	  {header:"进出线架设方式",dataIndex:"BDZ_SB_JSFS"},
              	  //{header:"地理经度（度）",dataIndex:"BDZ_JD_D"},
              	  //{header:"地理经度（分）",dataIndex:"BDZ_JD_F"},
              	  //{header:"地理经度（秒）",dataIndex:"BDZ_JD_M"},
              	  //{header:"地理纬度（度）",dataIndex:"BDZ_WD_D"},
              	  //{header:"地理纬度（分）",dataIndex:"BDZ_WD_F"},
              	  //{header:"地理纬度（秒",dataIndex:"BDZ_WD_M"},
              	  {header:"启动时间",dataIndex:"BDZ_SB_QDSJ"},
              	  {header:"申报单位",dataIndex:"BDZ_SB_SBDW"}
			],
			tbar:["->",
			    {
			       xtype:'textfield',
		           id:"txt"
			     
				},{
					text:'查询',   
					iconCls: "icon-search",
	                handler:function(){
	                    
	                     Ext.getCmp("bdz_grid").getStore().load({params:{txt:Ext.getCmp("txt").getValue()}});
	                    
	                }
				},{
					text: "添加",
					iconCls: "icon-add",
                        handler: function () {
                              Ext.getCmp("bdzForm").getForm().reset();
                               Ext.getCmp("Win").setSize(840,350);
                               Ext.getCmp('Win').show();
                               Ext.getCmp('Win').action='add'; 
                               Ext.getCmp('Win').center();
                               if(Ext.getCmp('Win').changeValue!='-1'||Ext.getCmp("bdzForm"))
                                {
                                    Ext.getCmp('Win').setTitle("添加变电站设备信息");
                                    Ext.getCmp("submit_btn").setText('添加');
                                }
                                if(!Ext.getCmp("bdzForm"))
                                {
                                    if(Ext.getCmp('Win').changeValue == '-1')
                                    {
                                        Ext.getCmp('Win').removeAll();
                                    }
                                    
                                    Ext.getCmp('Win').load({url:'BDZ_SBServlet',scripts:true,params:{loaditem:"add"}});
                                    Ext.getCmp('Win').changeValue = '1';
                                }
                        }
					
				},{
					 text: "修改",
                        iconCls: 'icon-update',
                        handler: function (){
                               if (Ext.getCmp("bdz_grid").getSelectionModel().getCount() == 1) {
                                    var recordNum = -1;
                                    for (var i = 0; i < Ext.getCmp("bdz_grid").getStore().getCount(); i++) {
                                        if (Ext.getCmp("bdz_grid").getSelectionModel().getSelected(0).get("BDZ_SB_BH") == Ext.getCmp("bdz_grid").getStore().getAt(i).get("BDZ_SB_BH")) {
                                            recordNum = i;
                                            break;
                                        }
                                    }
                                    Ext.getCmp("Win").setSize(840,350);
                                    Ext.getCmp('Win').show();
                                    Ext.getCmp('Win').action='update';
                                    Ext.getCmp('Win').recordNum=recordNum;
                                    Ext.getCmp('Win').center();
                                     Ext.getCmp("sb_bh").setReadOnly(true);
                                    if(Ext.getCmp('Win').changeValue!='-1'||Ext.getCmp("bdzForm"))
                                    {
                                        Ext.getCmp('Win').setTitle("变电站设备信息");
                                        Ext.getCmp("submit_btn").setText('保存');
                                        Ext.getCmp("bdzForm").getForm().loadRecord(Ext.getCmp("bdz_grid").getStore().getAt(recordNum));
                                        
                                      
                                    }

                                    if(!Ext.getCmp("bdzForm"))
                                    {
                                        if(Ext.getCmp('Win').changeValue == '-1')
                                        {
                                            Ext.getCmp('Win').removeAll();
                                        }
                                        Ext.getCmp('Win').load({url:'BDZ_SB_JBXX_Servlet',scripts:true,params:{loaditem:"add"}});
                                        Ext.getCmp('Win').changeValue = '1';
                                    }
                              }
                              else if (Ext.getCmp("bdz_grid").getSelectionModel().getCount() == 0) {
                                    Ext.Msg.alert("提示", "请最少选择一条记录");
                              }
                              else {
                                    Ext.Msg.alert("提示", "只能选择一条数据进行编辑");
                              }
                        
                        }
	 
				},{
					 text: "删除",
	                    iconCls: "icon-delete",
	                    handler: function () {
	                         if (Ext.getCmp("bdz_grid").getSelectionModel().getCount() > 0) {
                                    Ext.MessageBox.confirm('提示', '数据删除后不可还原,是否删除?', function (btn) {
                                        if (btn != "no") {
                                            var sbytList = "";
                                            for (var i = 0; i < Ext.getCmp("bdz_grid").getSelectionModel().getSelections().length; i++) {
                                                sbytList += Ext.getCmp("bdz_grid").getSelectionModel().getSelections()[i].get("BDZ_SB_BH");
                                                if (i < Ext.getCmp("bdz_grid").getSelectionModel().getSelections().length - 1) {
                                                      sbytList += ",";
                                                 }
                                            }
                                            var extAjax = Ext.Ajax;
                                            Ext.Msg.wait("提示","正在删除",{text:"正在删除数据..."});
                                            extAjax.request({
                                                url:"BDZ_SBServlet",
                                                method: 'POST',
                                                params:{action:"3",lst:sbytList},
                                                callback:function (object, bool, response) {
                                                	Ext.Msg.hide();
                                                    Ext.getCmp("bdz_grid").getStore().load({ params:{ start: 0, limit: 30} } );
                                                },
                                                failure: function (response) {
                                                    Ext.Msg.alert("提示", "操作出现了异常！");
                                                }
                                                
                                            });
                                        }
                                    });
                              }
                              else if (Ext.getCmp("bdz_grid").getSelectionModel().getCount() == 0) {
                                    Ext.Msg.alert("提示", "请最少选择一条记录");
                              }        
	                    }	
				}
			],
			listeners: {
				"rowdblclick":function(g,recordNum,e) {
					Ext.getCmp("bdzForm").getForm().reset();
					Ext.getCmp("Win").setSize(840,350);
                    win.show();
                    Ext.getCmp("sb_bh").setReadOnly(true);
                    
					
					win.action='update';
					win.setTitle('设备信息');
					Ext.getCmp("submit_btn").setText("修改");
					Ext.getCmp("bdzForm").getForm().loadRecord(Ext.getCmp("bdz_grid").getStore().getAt(recordNum));	
					    Ext.getCmp("jd_D").setValue(Ext.getCmp("bdz_grid").getStore().getAt(recordNum).get("BDZ_JD_D"));
					    Ext.getCmp("jd_F").setValue(Ext.getCmp("bdz_grid").getStore().getAt(recordNum).get("BDZ_JD_F"));
					    Ext.getCmp("jd_M").setValue(Ext.getCmp("bdz_grid").getStore().getAt(recordNum).get("BDZ_JD_M"));
					    Ext.getCmp("wd_D").setValue(Ext.getCmp("bdz_grid").getStore().getAt(recordNum).get("BDZ_WD_D"));
					    Ext.getCmp("wd_F").setValue(Ext.getCmp("bdz_grid").getStore().getAt(recordNum).get("BDZ_WD_F"));
					    Ext.getCmp("wd_M").setValue(Ext.getCmp("bdz_grid").getStore().getAt(recordNum).get("BDZ_WD_M"));
					    
                }
			}
		}
		MyViewport.superclass.initComponent.call(this);
	}
});

var jbxxItems=[
    {
        layout:"column",
        defaults:{columnWidth:.5,labelWidth:100,border:false},
        items:[
            //第一列
            {
                layout:"form",
                bodyStyle:'padding:15px 5px 0px 10px',
                defaultType:"textfield",
                defaults:{anchor:'92%',border:false},
                items:[                    
                    {
                        fieldLabel: "设备编号",
				        name:"BDZ_SB_BH",
				        id: "sb_bh",
                        tabIndex:1,
                        style:"color:#808080",
                        //autoCreate:{tag:"input",type:"text",maxLength:20},
                        validator:function(){
                            if(this.getValue().trim().length==0)
                            {
                                return "编号不能为空";
                            }
                            else
                            {
                                return true;
                            }
                        }
                    }, {
                        fieldLabel:"申报年度",
                     	name:"BDZ_SB_SBND",
                     	id: "sb_nd",
                        tabIndex:3,
                        //autoCreate:{tag:"input",type:"text",maxLength:128},
                         validator:function(){
                            if(this.getValue().trim().length==0)
                            {
                                return "年度不能为空";
                            }
                            else
                            {
                                return true;
                            }
                        }
                    }, {                        
                        
                        fieldLabel:"等级代码",
				        name:"BDZ_SB_DJDM",
				        id: "sb_da",
                        tabIndex:5,
                        editable: false,
				        maxLength: 64,
				        maxLengthText: "长度不能大于64位",
                        validator:function(){
                            if(this.getValue().trim().length==0)
                            {
                                return "年度不能为空";
                            }
                            else
                            {
                                return true;
                            }
                        }
                       
                       
                    }, {
                       fieldLabel:"法人代码",
				       name:"BDZ_SB_FRDM",
				       id: "sb_fr",
                       tabIndex:7,
                       editable: false,
                       maxLength: 64,
                       maxLengthText: "长度不能大于64位",
                       validator: function () {
                           if (this.getValue().trim().length == 0) {
                               return "名称不能为空";
                           }
                           else {
                               return true;
                           }
                       }
                    }, {
                        fieldLabel: "变电站名称",
                        name:"BDZ_MC",
                        id: "dz_mc",
                        tabIndex:9,
                        editable: false,
                        maxLength: 64,
                        maxLengthText: "长度不能大于64位",
                        validator: function () {
                            if (this.getValue().trim().length == 0) {
                                return "名称不能为空";
                            }
                            else {
                                return true;
                            }
                        }
                    }, {
                       xtype:"combo",
                       fieldLabel:"变电站类型名称",
                       name:"BDZLX_MC",
                       id:"BDZLX_MC",
                       tabIndex:11,
                       editable: false,
                       triggerAction:'all', 
                       store:new Ext.data.JsonStore({
                            fields:[{name:"BDZLX_BH"},{name:"BDZLX_MC"}],
                            root:'root',
                            url:"BDZLX_JBXX"
                        }),
                        mode:'local',
                       valueField: 'BDZLX_BH',
                       displayField: 'BDZLX_MC',
                       selectOnFocus:true,
                       emptyText:"请选择……"
                    },{
                       fieldLabel: "变电站地点",
		               name:"BDZ_DD",
		               id: "dz_dz",
                       tabIndex:15
                    },{
                    
                        xtype:"hidden",
		                id:"get_BH",
		                name:"BH_value"
                    
                    },{
                    
                        xtype:"hidden",
		                id:"BD_JD",
		                name:"BH_value"
                    
                    }
                ]
            },
            //第一列      
            //第二列
            {
                layout:"form",
                defaultType:"textfield",
                bodyStyle:'padding:15px 5px 0px 20px',
                defaults:{anchor:'92%',labelWidth:100,border:false},
                items:[
                    
                    {
				        fieldLabel: "主变压器名称",
                        name:"BDZ_ZBYQ_MC",
                        id: "by_mc",
				        tabIndex:4
				    },{
				        fieldLabel: "数量",
                        name:"BDZ_SB_SL",
                        id: "sb_sl",
				        tabIndex:6
				       
				    },{
				        fieldLabel: "主变压器型号",
                        name:"BDZ_ZBYQ_XH",
                        id: "by_xh",
				        tabIndex:8
				       
				    },{
                        fieldLabel: "最高电压（kV）",
                        name:"BDZ_SB_ZGDY",
                    	id: "sb_dy",
                        tabIndex:10

                    }, {
                        fieldLabel: "额定功率（kVA）",
                       	name:"BDZ_SB_EDGL",
                       	id: "sb_gl", 
                        tabIndex:12
                        
                    }, {
                        fieldLabel: "进出线架设方式",
                       	name:"BDZ_SB_JSFS",
                       	id: "sb_fs",
                        tabIndex:14
                    },{
		                xtype:"datefield",
		                fieldLabel:"启动时间",
		                name:"BDZ_SB_QDSJ",
		                editable: false,
		                id: "sb_sj",
		                format: 'Y-m-d',
		                value:new Date()
		           },{
		              fieldLabel: "申报单位", 
		              name:"BDZ_SB_SBDW",
		              id: "sb_dw"      
		            },{
                    
                        xtype:"hidden",
		                id:"BD_WD",
		                name:"BD_WD"
                    
                    }
                ]
            },
            //第二列
            {
                xtype:'hidden',
                id:'BDZ_JD_D',
                name:'BDZ_JD_D'
            },{
                xtype:'hidden',
                id:'BDZ_JD_F',
                name:'BDZ_JD_F'
            },{
                xtype:'hidden',
                id:'BDZ_JD_M',
                name:'BDZ_JD_M'
            },{
                xtype:'hidden',
                id:'BDZ_WD_D',
                name:'BDZ_WD_D'
            },{
                xtype:'hidden',
                id:'BDZ_WD_F',
                name:'BDZ_WD_F'
            },{
                xtype:'hidden',
                id:'BDZ_WD_M',
                name:'BDZ_WD_M'
            }    
          
        ]
    },{//坐标         
        layout:"column",
        xtype:"panel",
        border:false,
        defaults:{border:false,columnWidth:.5,labelWidth:110},
        id:"dl_location",
        items:[
            {
                bodyStyle:'padding:0px 5px 0px 1px',
                layout:"form",
                defaults:{anchor:"92%"},
                items:[
                    {
                        xtype:'compositefield',
                        fieldLabel:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;经度',
                        frame:false,
                        msgTarget:'side',
                        items:[
                            {
                                xtype:'numberfield',
                                id:'jd_D',
                                name:"度",
                                flex:.27,
                                autoCreate:{tag:"input",type:"text",maxLength:3},
                                allowDecimals:false,
                                maxValue:180,
                                maxText:"最大值为180度"
                            },{
                                xtype:'displayfield',value:'度'
                            },{
                                xtype:'numberfield',
                                id:'jd_F',
                                name:"分",
                                flex:.27,
                                autoCreate:{tag:"input",type:"text",maxLength:2},
                                allowDecimals:false,
                                maxValue:60,
                                maxText:"最大值为60分"
                            },{
                                xtype:'displayfield',value:'分'
                            },{
                                xtype:'numberfield',
                                id:'jd_M',
                                name:"秒",
                                flex:.46,
                                autoCreate:{tag:"input",type:"text",maxLength:6},
                                decimalPrecision:3,
                                maxValue:60,
                                maxText:"最大值为60秒"
                            },{
                                xtype:'displayfield',value:'秒'
                            }
                        ]
                    }
                ]
                
            },{
                bodyStyle:'padding:0px 5px 0px 11px',
                layout:"form",
                defaults:{anchor:"92%"},
                items:[
                    {
                        xtype:'compositefield',
                        fieldLabel:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;纬度',
                        msgTarget:'side',
                        items:[
                            {
                                xtype:'numberfield',
                                name:"度",
                                id:'wd_D',
                                flex:.27,
                                autoCreate:{tag:"input",type:"text",maxLength:2},
                                allowDecimals:false,
                                maxValue:90,
                                maxText:"最大值为90度"
                            },{
                                xtype:'displayfield',value:'度'
                            },{
                                xtype:'numberfield',
                                id:'wd_F',
                                name:"分",
                                flex:.27,
                                autoCreate:{tag:"input",type:"text",maxLength:2},
                                allowDecimals:false,
                                maxValue:60,
                                maxText:"最大值为60分"
                            },{
                                xtype:'displayfield',value:'分'
                            },{
                                xtype:'numberfield',
                                id:'wd_M',
                                name:"秒",
                                flex:.46,
                                autoCreate:{tag:"input",type:"text",maxLength:6},
                                decimalPrecision:3,
                                maxValue:60,
                                maxText:"最大值为60秒"
                            },{
                                xtype:'displayfield',value:'秒'
                            }
                        ]
                    }
                ]
            }
        ]
    }
    //坐标
    
]

var win=new Ext.Window({
    title: '添加新设备',
    closable:true,
    layout:'fit',
    id: "Win",
    oper:'add',
    closeAction:'hide',
    resizable:false,
    autoDestroy:true,
    modal:true,
    width:900,
    height:530,
    action:'add',
    items:[
       {
          xtype:"form",
          id:"bdzForm",
          layout:"form",
          border:false,
          defaults:{border:false,labelWidth:100},
          items:jbxxItems,
          buttons:[
               {
                   text:"添加",
                    id:"submit_btn",
                    handler:function(){
                    	if(Ext.getCmp("bdzForm").getForm().isValid() == true){
                    	
                    	        Ext.getCmp("get_BH").setValue(Ext.getCmp("BDZLX_MC").getValue());
                    		   Ext.getCmp('BDZ_JD_D').setValue(Ext.getCmp('jd_D').getValue());
                    		   Ext.getCmp('BDZ_JD_F').setValue(Ext.getCmp('jd_F').getValue());
                    		   Ext.getCmp('BDZ_JD_M').setValue(Ext.getCmp('jd_M').getValue());
                    		   Ext.getCmp('BDZ_WD_D').setValue(Ext.getCmp('wd_D').getValue());
                    		   Ext.getCmp('BDZ_WD_F').setValue(Ext.getCmp('wd_F').getValue());
                    		   Ext.getCmp('BDZ_WD_M').setValue(Ext.getCmp('wd_M').getValue());
                    		
	                    	if(win.action=='add'){
		                        Ext.getCmp("bdzForm").getForm().submit({
		                            waitMsg : '正在提交表单数据,请稍候...',
		    						waitTitle : '正在验证数据...',
		                            method:"POST",
		                            url:"BDZ_SBServlet",
		                            params : {action:"1" },
		                            success:function(form,action){
		                            	Ext.Msg.hide();
		                                Ext.getCmp("bdz_grid").getStore().load();
		                                Ext.getCmp("bdzForm").getForm().reset();
		                              
		                            },
		                            failure:function(form,action){
		                                Ext.Msg.alert("提示","操作出现了异常！");
		                            }
		                        });
	                        }else if(win.action=='update'){
	                        	Ext.getCmp("bdzForm").getForm().submit({
		                            waitMsg : '正在提交表单数据,请稍候...',
		    						waitTitle : '正在验证数据...',
		                            method:"POST",
		                            url:"BDZ_SBServlet",
		                            params : {action:"2" },
		                            success:function(form,action){
		                            	Ext.Msg.hide();
		                            	Ext.getCmp("bdz_grid").getStore().load();
		                            	win.hide();
		                            },
		                            failure:function(form,action){
		                            	Ext.Msg.alert("提示","操作出现了异常！");
		                            }
		                        });
	                        }
	                    }
                    }
              
              },{
                       text:"取消",
                       handler:function(){
                            Ext.getCmp("Win").hide();
                            Ext.getCmp("bdzForm").getForm().reset();
                        }
                      
                }
             
           ]
       }
    
    
    ],
    listeners:{
    	'hide':function(){     
    		Ext.getCmp("bdzForm").getForm().reset();
    	},
    	'afterrender':function(){
    		 //Ext.getCmp("BDZLX_BH").getStore().load();
		     Ext.getCmp("BDZLX_MC").getStore().load();
    	}
    }
});

Ext.onReady(function () {
    var viewport = new MyViewport();
    viewport.render();
});

</script>
</head>
<body id="dom">

</body>
</html>